package cn.edu.scau.dropship.mapper;

import cn.edu.scau.dropship.entity.Brand;
import cn.edu.scau.dropship.entity.BrandExample;
import java.util.List;
import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.ConstructorArgs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface BrandMapper {
    @SelectProvider(type=BrandSqlProvider.class, method="countByExample")
    long countByExample(BrandExample example);

    @DeleteProvider(type=BrandSqlProvider.class, method="deleteByExample")
    int deleteByExample(BrandExample example);

    @Delete({
        "delete from brand",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into brand (id, name, ",
        "mvo_id, image)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{mvoId,jdbcType=INTEGER}, #{image,jdbcType=VARCHAR})"
    })
    int insert(Brand record);

    @InsertProvider(type=BrandSqlProvider.class, method="insertSelective")
    int insertSelective(Brand record);

    @SelectProvider(type=BrandSqlProvider.class, method="selectByExample")
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="name", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="mvo_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER),
        @Arg(column="image", javaType=String.class, jdbcType=JdbcType.VARCHAR)
    })
    List<Brand> selectByExample(BrandExample example);

    @Select({
        "select",
        "id, name, mvo_id, image",
        "from brand",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ConstructorArgs({
        @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="name", javaType=String.class, jdbcType=JdbcType.VARCHAR),
        @Arg(column="mvo_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER),
        @Arg(column="image", javaType=String.class, jdbcType=JdbcType.VARCHAR)
    })
    Brand selectByPrimaryKey(Integer id);

    @UpdateProvider(type=BrandSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Brand record, @Param("example") BrandExample example);

    @UpdateProvider(type=BrandSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Brand record, @Param("example") BrandExample example);

    @UpdateProvider(type=BrandSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Brand record);

    @Update({
        "update brand",
        "set name = #{name,jdbcType=VARCHAR},",
          "mvo_id = #{mvoId,jdbcType=INTEGER},",
          "image = #{image,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Brand record);
}